﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/top.jsp"%>
<form id="searchForm" name="searchForm" action="" method="post">
<input type="hidden" name="p" id="p" value="1" />		
	<table>
		<tbody>
			<tr>
				<th style="border:0px;"><img src="${ctx}/static/images/pages/cen/rig/ico_01.png" align="absmiddle">&nbsp;向导式填报</th>
			</tr>
			   <tr class="tab_grey">
      <td style="border:0px;">
   <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表制度
					 <!-- onchange="getVersionList($('#reportSystem').val());" -->
					<select class="tab_textbut" id="reportSystem" name="reportSystem" onchange="showdate();">
					<option value="">--请选择--</option>
						<c:forEach var="system" items="${systemList}">
							<option value="${system.code}">${system.codeName}</option>
						</c:forEach>
					</select>
					
      </td>
      </tr>
      <c:if test="${empty param['reportSystem']}">
 <tr class="tab_grey" id="datetr" style="display:none">
</c:if>
 <c:if test="${not empty param['reportSystem']}">
        <tr class="tab_grey" id="datetr">
        </c:if>
      <td style="border:0px;">
   <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表日期
					 <!-- onchange="getReportTypeList($('#reportYear').val());" -->
				<input type="text" name="reportDate" id="reportDate" value="${reportDate}" size="20" onclick="WdatePicker({dateFmt:'yyyy-MM',minDate:'1995-01-01',maxDate:'%y-%M-%d',onpicked:changeVs})" class="Wdate"/>
      </td>
      </tr>
            <c:if test="${empty reportDate}">
 <tr class="tab_grey" id="reporttr" style="display:none">
</c:if>
<c:if test="${not empty param['reportSystem']}">
 <c:if test="${not empty reportDate}">
        <tr class="tab_grey" id="reporttr">
        </c:if>
        <c:if test="${empty reportDate}">
 <tr class="tab_grey" id="reporttr" style="display:none">
</c:if>
        </c:if>
         <c:if test="${empty param['reportSystem']}">
  <tr class="tab_grey" id="reporttr" style="display:none">
</c:if>
      <td style="border:0px;">
   <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表
			<select id="repId" name="repId" style="width:300px"  class="tab_textbut" onchange="showunit();">
			<option value="">...</option>
				<c:forEach var="rep" items="${repList}">
                   <option value="${rep.id}" id="${rep.newId}">${rep.typeName}</option>
                </c:forEach>
           </select>
            </td>
      </tr>
       <c:if test="${empty repList}">
 <tr class="tab_grey" id="proxytr" style="display:none">
</c:if>
 <c:if test="${not empty repList}">
        <tr class="tab_grey" id="proxytr">
        </c:if>
      <td style="border:0px;">
   <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />
   若是代填&nbsp;&nbsp;<input type="radio" id="isProxy" name="isProxy" checked="checked" value="0">否  &nbsp;&nbsp; <input type="radio" id="isProxy" name="isProxy" value="1">是
				<span style="display:none" id="proxyUnit">
				请点放大镜选择代填单位
				<img src="${ctx}/static/images/icons/ss1.gif" onclick="chooseUnit()" style="cursor:pointer"/></span>
				     </td>
      </tr>
          <c:if test="${empty repList}">
 <tr class="tab_grey" id="unittr" style="display:none">
</c:if>
 <c:if test="${not empty repList}">
        <tr class="tab_grey" id="unittr">
        </c:if>
      <td style="border:0px;">
   <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />填报单位名称
			<input class="tab_textbut" id="chooseUser" name="chooseUser" type="hidden" readonly="readonly" value="${chooseUser}">
			<input class="tab_textbut" id="unitId" name="unitId" type="hidden" readonly="readonly" value="${unitId}">
				<input class="tab_textbut" id="unitName" name="unitName" type="text" readonly="readonly" value="${unitName}">
				<input type="button" value="填报" class="tab_but" onclick="return submitForm();"/> 
				     </td>
      </tr>
     
		</tbody>
	</table>
	
			<div>
					
					<!--  <a class="tab_but02" href="#" onclick="">下载制度报表模板</a>
					<input type="button" class="tab_but"  onclick="reportExport();" value="下载模板" onfocus="this.blur()"/>
				    <input type="button" class="tab_but"  onclick="mutiImportWin();" value="批量导入"/>-->
					<input type="button" value="查询" class="tab_but" onclick="return reSubmit();" /> 
	<c:if test="${not empty obj.operationResult}">
					<input type="button" class="tab_but"  onclick="exportReport('${ctx}');" value="导出选中" onfocus="this.blur()"/>
		    		<input type="button" class="tab_but"  onclick="setSubmitFlag('${ctx}');" value="提交选中" onfocus="this.blur()"/>
		    		<input type="button" class="tab_but"  onclick="setDeleteFlag('${ctx}');" value="删除选中" onfocus="this.blur()"/>
	</c:if>
					<!--		<font style="color:red">(批量导入需在文件名前补充报表时间和单位。代填单位需与系统中单位名称一致，日期格式为XXXX年X月第X季度，名称间以'_'间隔,示例如下：) </font>
	<br/>
	<font style="color:red">(年报：2014年_XXX单位_XXX报表。月报：2014年5月_XXX单位_XXX报表。季报：2014年5月第2季度_XXX单位_XXX报表) </font> -->
	
				</div>

		
</form>
<script>

$(function(){
	
	//绑定代填事件
	$("input[type='radio']").each(function(){	
		$(this).bind("click", function(){
			if ($(this).attr("value")=="1"){
				$("#proxyUnit").show();
				$("#proxyUnit").css("color", "red");
				$("#unitId").val("");
				$("#unitName").val("");
				$("#chooseUser").val("");
			}else{
				$("#proxyUnit").hide();
				$("#unitId").val("${sessionScope.user.userUnitId}");
				$("#unitName").val("${sessionScope.user.userUnit}");
				$("#chooseUser").val("${sessionScope.user.id}");
			}
		});	
	});

	if ("${sessionScope.user.userUnitId == unitId}"=="false"){
		$("input[type='radio']").each(function(){
			if ($(this).attr("value")=="1"){
				$(this).attr("checked", "checked");
				$("#proxyUnit").show();
				$("#proxyUnit").css("color", "red");
			}
		});
	}

	
});

//报表制度
$("#reportSystem").val("${param['reportSystem']}");
$("#reportVersion").val("${param['reportVersion']}");
$("#repId").val("${param['repId']}");
function clearInput() {
	$("#reportSystem").val("");
	$("#reportDate").val("");
}

//查找直属单位
function chooseUnit(){
	openWin("查询单位","${baseURL}/unit/find?reportId="+$("#repId").val(),$(window).width()-50,$(window).height(),setValue);
}

function setValue(data) {
    document.getElementById("chooseUser").value = data.userId;
    document.getElementById("unitName").value = data.unitName;
    document.getElementById("unitId").value = data.unitId;
    
}
//批量导入
function mutiImportWin()
{
	openWin("批量导入","${baseURL}/data/preMutiImport",500);
}

function reportExport()
{
	var url="${ctx}/reports/service.do?method=downTemples&countyId=${user.id}";
	openWin("下载报表模板",url);
}

function reportSearch()
{
	var date=$("#reportDate").val();
	$('#searchForm').attr("action","${ctx}/report/searchReport?checkStatus=0&sysId="+$("#reportSystem").val());
	$("#searchForm").submit();
}

	function showdate()
	{
		if($("#reportSystem").val()!="")
		{
			$("#datetr").css('display','block'); 
			$("#reporttr").css('display','block'); 
			changeVs();
		}
		else
		{
			$("#datetr").css('display','none'); 
			$("#reporttr").css('display','none'); 
			$("#unittr").css('display','none'); 
			$("#proxytr").css('display','none');
		}
	}
	
	function showunit(){
		if($("#repId").val()!="0")
		{
			$("#unittr").css('display','block'); 
			$("#proxytr").css('display','block');
		}
		else
		{
			$("#unittr").css('display','none'); 
			$("#proxytr").css('display','none');
		}
	}
	
	function changeVs(sysId,vsId) {
		var sysId=$("#reportSystem").val();
		var vsId=$("#reportDate").val();
		$.getJSON("${baseURL}/monitor/changeRsForDate?sysId="+sysId+"&date="+vsId, function(data) {
			$("#repId").empty();
			$("#repId").append("<option value='0'>...</option>");
		 	$.each(data, function(i, item) {
	            $("#repId").append( "<option id='"+item.newId+"' value='" + item.id + "'>" + item.typeName + "</option>" );
	        });
	 });
	}
	
	function submitForm()
	{
		var date=$("#reportDate").val();
		
		if ($("#repId").val()==""){
			layer.alert("请需要填报的报表。");
			return false;
		}
		if (date==""){
			layer.alert("请选择填报日期。");
			return false;
		}
		
		openReportWin($("#chooseUser").val(),$("#repId").val());
	}
	
	function importForm()
	{
		var date=$("#reportDate").val();
		openImportWin($("#chooseUser").val(),$("#repId").val(),date);
	}
	
	function selectAll(checkAllFlag) {
		var checkArray = document.getElementsByName("chk");
		for (var i = 0; i < checkArray.length; i++) {
			checkArray[i].checked = checkAllFlag;
		}
	}
	
	//导入
	function openImportWin(unitId,reportTypeId,date){
		var url="${ctx}/data/preImport?unitId="+unitId+"&reportProxyId=${user.id}&reportTypeId="+reportTypeId+
			"&timeType=" + reportTimetype + "&yearType=" + reportYearTime + "&quarterDate=" +
			reportQuarter + "&timeDate=" + reportMonth+"&status="+status;
		openWin("导入报表",url,null,200,reSubmit);
	}
	
	//查看历史窗口
	function openHistoryWin(id){
		var url="${ctx}/data/view?id="+id;
		openWin("审核历史",url);
	}
	
	//查看
	function openViewWin(id){
		var url="${ctx}/reports/service.do?method=showReportInfo&reportOperatorId=${user.id}&reportId="+id;
		openWin("查看报表",url,null,550);
	}
	
	//填报
	function openReportWin(userId,reportTypeId){
		var date=$("#reportDate").val();
		
		var url="${ctx}/reports/service.do?method=showCreateReport&reportOperatorId="+userId+"&reportProxyId=${user.id}&reportTypeId="+reportTypeId+
		"&reportDate="+date;
		openWin("报表填报",url,null,550,reSubmit);
	}

	//修改
	function openEditWin(id){
		var url="${ctx}/reports/service.do?method=showReportUpdate&reportOperatorId=${user.id}&reportId="+id;
		openWin("修改报表",url,null,550,reSubmit);
	}
	//重新提交表单
	function reSubmit(){
		var date=$("#reportDate").val();
		$('#searchForm').attr("action","${ctx}/report/searchReport?checkStatus=0&sysId="+$("#reportSystem").val());
		$("#searchForm").submit();
	}
	</script>
	
<c:if test="${empty obj.operationResult}">
	<b>没有符合条件的记录。</b>
</c:if>
<c:if test="${not empty obj.operationResult}">
<div style="height:400px; overflow-y:scroll;">
	<table id="listTable">
		<tbody>
			<tr>
				<th width="5%"><input type="checkbox" onclick="selectAll(this.checked);"></th>
				<th width="50%">报表名称</th>
				<th width="12%">填报期间</th>
				<th width="12%">操作</th>
			</tr>
			<c:forEach var="oneRow" items="${obj.operationResult}">
				<tr>
					<td><input name="chk" type="checkbox" id="chk" value="${oneRow.id}|${oneRow.reportCheckStatus}" /></td>
					<td align="left" >${oneRow.reportName}</td>
					<td align="left" >${oneRow.reportMonth}</td>
					<td align="left" >
						
					<c:choose>
					<c:when test="${oneRow.reportCheckStatus==3}"><a href="#" class="tab_text01" onclick="openEditWin('${oneRow.id}');return false;">修改</a></c:when>
					<c:when test="${oneRow.status==2}"><a href="#" class="tab_text01" onclick="openReportWin('${oneRow.userId}','${oneRow.reportTypeId}');return false;">迟报</a></c:when>
					<c:when test="${oneRow.reportCheckStatus==0}"><a href="#" class="tab_text01" onclick="openEditWin('${oneRow.id}');return false;">修改</a></c:when>
					<c:when test="${oneRow.status==4}"><a href="#" class="tab_text01" onclick="openViewWin('${oneRow.id}');return false;">查看</a></c:when>
						</c:choose>
					</td>
				</tr>
			</c:forEach>
		<tr class="tab_grey">
				<td colspan="9" align="center" valign="middle" class="tab_white">
				<div class="pagination"> 
					<%@ include file="../include/listpage2.jsp"%>
				</div>
				<div class="clear"></div>
				<form action="${ctx}/report/exportReport" method="post" id="exportForm" name="exportForm">
	
		<input type="hidden" name="idStr" id="exportIdStr"/>
		</form>
				</td>
			</tr>
		</tbody>
	</table>
	</div>
	<script src="${ctx}/static/ocean/js/listReport.js"></script>
</c:if>
<%@ include file="/static/include/bottom.jsp"%>
